
window.onload = function () {
    setLoginInfo()
    findAll();
}
function findAll() {
  axios.get("/channel/findAll").then(resp=>{
      var info = resp.data;
      var str ="";
      info.forEach(n=>{
          str+=`<tr><td>${n.channelName}</td><td>${n.channelContent}</td><td>${n.postNum}</td>
<td><input type="button" value="查看" onclick="location.href='/post.html?id=${n.id}'" ></td></tr>`;
      });
      $("data").innerHTML = str;
  });
}
function setLoginInfo() {
    axios.get("/user/getLoginUser").then(resp=>{
        var info = resp.data;
        if(info == ''){
            $("loginDiv").innerHTML = "对不起，请先<a href='/login.html'>登陆</a>";
        }
        else{
            var str = "";
                str+=`<img src="/emFace/${info.userImg} " width="100" height="100"><br>
                 欢迎光临：${info.userName}<br>
                 用户邮箱：${info.userMail}<br>`;
            $("loginDiv").innerHTML = str;
        }
    });
}